package sysuser

import (
	"context"
	"jinrigaoping/api/platform/internal/svc"
	"jinrigaoping/api/platform/internal/types"
	"jinrigaoping/rpc/sys/sys"

	"github.com/zeromicro/go-zero/core/logx"
)

type SysUserInfoLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewSysUserInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SysUserInfoLogic {
	return &SysUserInfoLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *SysUserInfoLogic) SysUserInfo(req *types.SysUserInfoReq) (resp *types.SysUserInfoRes, err error) {

	info, err := l.svcCtx.SysRpc.SysUserInfo(l.ctx, &sys.SysUserInfoReq{Id: req.Id})
	if err != nil {
		return nil, err
	}

	return &types.SysUserInfoRes{
		Id:       info.Id,
		Account:  info.Account,
		Status:   info.Status,
		RoleId:   info.RoleId,
		Nickname: info.Nickname,
		Phone:    info.Phone,
		Brief:    info.Brief,
		Email:    info.Email,
	}, nil
}
